<template>
  <div class="container">
    <a-typography-title :heading="1">Offer 来啦！</a-typography-title>
    <a-typography-title :heading="3">HaHo 平台运营商</a-typography-title>
    <a-typography-text>张三邀请您加入互联网中心团队</a-typography-text>
    <div>
      <a-form ref="formRef" :style="{ width: '600px' }" @submit="handleSubmit">
        <a-form-item field="name" label="Username" validate-trigger="blur">
          <a-input
            v-model="form.name"
            placeholder="please enter your username..."
          />
        </a-form-item>
        <a-form-item field="email" label="email">
          <a-input
            v-model="form.email"
            placeholder="please enter your email..."
          />
        </a-form-item>
        <a-form-item field="ip" label="IP">
          <a-input v-model="form.ip" placeholder="please enter your ip..." />
        </a-form-item>
        <a-form-item field="url" label="URL">
          <a-input v-model="form.url" placeholder="please enter your url..." />
        </a-form-item>
        <a-form-item field="match" label="match">
          <a-input
            v-model="form.match"
            placeholder="please enter your match..."
          />
        </a-form-item>
        <a-form-item>
          <a-space>
            <a-button html-type="submit">提交</a-button>
          </a-space>
        </a-form-item>
      </a-form>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { reactive } from 'vue';

  const handleSubmit = ({ values, errors }) => {
    console.log('values:', values, '\nerrors:', errors);
  };

  const form = reactive({
    name: '',
    password: '',
    password2: '',
    email: '',
    ip: '192.168.2.1',
    url: '',
    match: '',
  });

  const rules = {
    name: [
      {
        required: true,
        message: 'name is required',
      },
    ],
    password: [
      {
        required: true,
        message: 'password is required',
      },
    ],
    password2: [
      {
        required: true,
        message: 'password is required',
      },
      {
        validator: (value, cb) => {
          if (value !== form.password) {
            cb('two passwords do not match');
          } else {
            cb();
          }
        },
      },
    ],
    email: [
      {
        type: 'email',
        required: true,
      },
    ],
    ip: [
      {
        type: 'ip',
        required: true,
      },
    ],
    url: [
      {
        type: 'url',
        required: true,
      },
    ],
    match: [
      {
        required: true,
        validator: (value, cb) => {
          return new Promise((resolve) => {
            if (!value) {
              cb('Please enter match');
            }
            if (value !== 'match') {
              cb('match must be match!');
            }
            resolve();
          });
        },
      },
    ],
  };
</script>

<script lang="ts">
  export default {
    // 实名认证
    name: 'SignUpAuthPerson',
  };
</script>

<style lang="less" scoped>
  .container {
    display: flex;
    height: 100vh;

    .banner {
      width: 550px;
      background: linear-gradient(163.85deg, #1d2129 0%, #00308f 100%);
    }

    .content {
      position: relative;
      display: flex;
      flex: 1;
      align-items: center;
      justify-content: center;
      padding-bottom: 40px;
    }

    .footer {
      position: absolute;
      right: 0;
      bottom: 0;
      width: 100%;
    }
  }

  .logo {
    position: fixed;
    top: 24px;
    left: 22px;
    z-index: 1;
    display: inline-flex;
    align-items: center;

    &-text {
      margin-right: 4px;
      margin-left: 4px;
      color: var(--color-fill-1);
      font-size: 20px;
    }
  }
</style>

<style lang="less" scoped>
  // responsive
  @media (max-width: @screen-lg) {
    .container {
      .banner {
        width: 25%;
      }
    }
  }
</style>
